﻿using System.Buffers;

namespace Acl.Messages;

/// <summary>
/// 分布式消息发布器
/// </summary>
public interface IDistributionMessagePublisher
{
    /// <summary>
    ///发布可一个负载内容为空的消息
    /// </summary>
    /// <param name="topic">消息主题</param>
    /// <param name="data">消息内容</param>
    /// <param name="opts">发布选项</param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    ValueTask Publish(string topic, in DistributionPublishOptions? opts = default, CancellationToken cancellationToken = default);

    /// <summary>
    ///发布一个负载内容可序列化的消息
    /// </summary>
    /// <param name="topic">消息主题</param>
    /// <param name="data">消息内容</param>
    /// <param name="opts">发布选项</param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    ValueTask Publish<T>(string topic, T? data = default, in DistributionPublishOptions? opts = default, CancellationToken cancellationToken = default);
}
